package com.playball.lottery.customview;

import java.util.ArrayList;

import com.playball.lottery.R;
import com.playball.lottery.util.DefConstants;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * 
* @ClassName: LuckyNumShowAdapter 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author vanszhen 
* @date 2014年5月9日 上午11:58:16 
*
 */
public class LuckyNumShowAdapter extends BaseAdapter{
	/**数组 集合*/
	private ArrayList<int []> arrNums  ;
	private Context context;
	/** LayoutInflater */
	private LayoutInflater inflater;
	//类型
	private int type ;
	public LuckyNumShowAdapter(Context context) {
		super();
		this.context = context;
		this.inflater = LayoutInflater.from(context);
	}

	public void setData(ArrayList<int []> arrNums ,int type ){
		this.arrNums = arrNums ;
		this.type = type ;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arrNums.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return arrNums.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		if(convertView==null){
			 convertView = inflater.inflate(R.layout.jdd_lucky_selnum_item, null); 
		}
		TextView txtNum = (TextView) convertView.findViewById(R.id.lucky_num);
		
		int [] nums = arrNums.get(position);
		if(nums.length>0){
			String numsRedStr ="";
		    String numsBuleStr ="";
		    if(type == DefConstants.LOT_ID_SSQ){
		    	for (int i = 0; i < nums.length; i++) {
					if(i < nums.length-1){
						numsRedStr+=nums[i]+" ";
					}else{
						numsBuleStr = nums[i] +" ";
					}
					
				}
		    	//txtNum.setText(Html.fromHtml("我是<font color=blue>danyijiangnan</font>")); 
		    //	String shownum =numsRedStr +" - "+ Html.fromHtml("<font color=#66CD00>" + numsBuleStr + "</font>");
		    	txtNum.setText(      Html.fromHtml( numsRedStr+"  "+ "<font color=#2997e5>" + numsBuleStr + "</font>"));
		    }else if(type == DefConstants.LOT_ID_DLT){
		    	for (int i = 0; i < nums.length; i++) {
					if(i < nums.length-2){
						numsRedStr+=nums[i]+" ";
					}else{
						numsBuleStr += nums[i] +" ";
					}
					
				}
		    	txtNum.setText(   Html.fromHtml(numsRedStr+"  "+"<font color=#2997e5>" + numsBuleStr + "</font>"));
		    }else{
		    	for (int i = 0; i < nums.length; i++) {
						numsRedStr+=nums[i]+" ";
				}
		    	txtNum.setText(numsRedStr);
		    }
		
		}else{
			
		}
		
		
		//tv_selectNum.setText(Html.fromHtml("已经选择" + "<font color=#a50000>" + 0+ "</font>" + "场比赛"));
		
		return convertView;
	}
}
